package name.sakanacatcher;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.IOException;

@SpringBootApplication
public class ComMsServerApplication {

    public static void main(String[] args) throws IOException {
        int port = 8080;
        String portPrefix = "--server.port=";
        for (String arg : args) {
            if (arg.startsWith(portPrefix)) {
                port = Integer.parseInt(arg.substring(portPrefix.length()));
            }
        }
        SpringApplication.run(ComMsServerApplication.class, args);
//        String osName = System.getProperty("os.name");
//        String url = "http://localhost:" + port;

//        if (osName.startsWith("Mac OS")) {
//            Class fileMgr = null;
//            try {
//                fileMgr = Class.forName("com.apple.eio.FileManager");
//                Method openURL = fileMgr.getDeclaredMethod("openURL", String.class);
//                openURL.invoke(null, url);
//            } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
//                e.printStackTrace();
//            }
//
//        } else if (osName.startsWith("Windows")) {
////            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
//        }
    }

}
